home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-07-15 | 9.6 KB | 228 lines | [TEXT/MPS ] |
- //----------------------------------------------------------------------------------------
- // UTwistDownView.h
- // ETO20 MacApp 3.3.1, MPW 3.4.1
- // Copyright ©1994-1996 Conrad Kopala
- // Twist Down Lists version 2.0a0 7/15/96
- //----------------------------------------------------------------------------------------
-
- #ifndef __UTWISTDOWNVIEW__
- #define __UTWISTDOWNVIEW__
-
- #ifndef __UTWISTDOWNGLOBALS__
- #include "UTwistDownGlobals.h" //required here for EWritingDirection
- #endif
-
- //MacApp stuff
- #ifndef __UADORNERS__
- #include "UAdorners.h"
- #endif
-
- #ifndef __UDIALOG__
- #include "UDialog.h"
- #endif
-
- #ifndef __UDRAWINGENVIRONMENT__
- #include "UDrawingEnvironment.h"
- #endif
-
- #ifndef __UGRIDVIEW__
- #include "UGridView.h"
- #endif
-
- #ifndef __UCOMMAND__
- #include "UCommand.h"
- #endif
-
- //ToolBox stuff
-
- #ifndef __TEXTEDIT__
- #include "TextEdit.h" //Needed for TextStyle PPC
- #endif
-
- //ANSI stuff
- //None
- //----------------------------------------------------------------------------------------
- // Forward and external classes
- //----------------------------------------------------------------------------------------
- class TTwistDownApp; //external
- class TTwistDownDocument; //external
- class TTwistDownElement; //external
- class TTwistDownControl; //external
- class TTwistDownView; //forward
-
-
- //----------------------------------------------------------------------------------------
- // TChangeFontSizeDialog
- //----------------------------------------------------------------------------------------
- class TChangeFontSizeDialog: public TView
- {
- MA_DECLARE_CLASS;
-
- public:
- TChangeFontSizeDialog::TChangeFontSizeDialog();
- virtual ~TChangeFontSizeDialog();
- void TChangeFontSizeDialog::IChangeFontSizeDialog(TDocument* itsDocument,TView* itsSuperView,
- const VPoint& itsLocation,const VPoint& itsSize,SizeDeterminer itsHSizeDet,SizeDeterminer itsVSizeDet);
-
- void TChangeFontSizeDialog::GetNewFontSize(long& newSize);
- void TChangeFontSizeDialog::SetNewSize(long& newSize);
- };
-
- //----------------------------------------------------------------------------------------
- // TTwistDownView
- //----------------------------------------------------------------------------------------
- class TTwistDownView: public TTextListView, public MScriptableObject
- {
- MA_DECLARE_CLASS;
-
- public:
- TTwistDownDocument* fTwistDownDocument;
- VPoint fTwistDownControlSize;
- PolyHandle fOpenTriangle;
- PolyHandle fClosedTriangle;
- PolyHandle fIntermediateTriangle;
- Boolean fCouldExpandAll;
- Boolean fCouldCollapseAll;
-
- Boolean fIsFirstClick;
-
- long fNumberOfControls; //This is used to keep a running count of the number of controls that exist
- //at any time. When a new twistDownControl is made, fNumberOfControls is
- //incremented. When a twistDownControl is freed, fNumberOfControls is
- //decremented. Having this count available is useful for finding mistakes in
- //the program.
-
- long fInitialNumberOfControls; //This is the number of controls that existed when the document opened.
- //It never changes after the document is opened. Note that
- //fNumberOfControls can never be less than fInitialNumberOfControls.
-
- Boolean fControlCountingEnabled; //This is used in conjunction with fInitialNumberOfControls
- //and IncrementInitialNumberOfControls(). fControlCountingEnabled
- //is initially set to FALSE. While it is FALSE, fInitialNumberOfControls
- //is incremented. The last thing CreateVisibleList() does is
- //set fControlCountingEnabled to TRUE.
-
- long fNumberOfExpandedControls; //A running count of the number of expanded controls and
- long fNumberOfCollapsedControls; //collapsed controls is kept.
-
- EWritingDirection fWritingDirection;
-
- VPoint fTwistDownControlLocation; //This is used to hold the horizontal coordinate of twistDownControls.
- //If we're writing left-to-right, the controls are on the left side of
- //the twistDownView. If we're writing right-to-left, the controls are
- //on the right side of the twistDownView.
- //fTwistDownControlLocation.v = 0 always.
- //if GetSysDirection() == 0 (writing left-to-right) then
- //fTwistDownControlLocation.h = 0.
- //
- //if GetSystemDirection() == -1 (writing right-to-left) then
- //fTwistDownControlLocation.h
- // = TTwistDownView.fSize.h - TTwistDownView.fTwistDownControlSize.h.
- //
- //Its value is set by TTwistDownView::CreateTwistDownTriangles which is
- //where fTwistDownControlSize is determined (fTwistDownControlSize is
- //dependent on the font size).
- //
- //Its value is also set by TTwistDownView::SuperViewChangedFrame which
- //is called when the window's size is changed. The frame and size of
- //the twistDownView is changed by SetFrame which in turn calls
- //NotifySubViewsOfFrameChange. We need to set the value of
- //fTwistDownControlLocation.h before the twistDownControls are notified that
- //their superview has changed its frame.
-
- TTwistDownView::TTwistDownView();
- virtual ~TTwistDownView();
-
- virtual void TTwistDownView::ITwistDownView(TTwistDownDocument* itsDocument, TView* itsSuperView,
- const VPoint& itsLocation, const VPoint& itsSize);
-
- virtual void TTwistDownView::DoPostCreate(TDocument* itsDocument);
-
- virtual void TTwistDownView::DoSetupMenus();
- virtual void TTwistDownView::DoMenuCommand(CommandNumber aCommandNumber);
-
- virtual Boolean TTwistDownView::HandleMouseDown(const VPoint& theMouse,TToolboxEvent* event,
- CPoint hysteresis,EMouseDownType mouseDownType);
-
- void TTwistDownView::GetViewSize(VPoint& viewSize);
-
- OSErr TTwistDownView::CreateVisibleList();
- OSErr TTwistDownView::BuildVisibleList(short rowNumber);
- void TTwistDownView::ResizeTwistDownViewRows();
- short TTwistDownView::CalculateColumnWidth();
- void TTwistDownView::RevealRight(Boolean redraw);
-
- virtual void TTwistDownView::SuperViewChangedFrame(const VRect& oldFrame,const VRect& newFrame,Boolean invalidate);
-
- // SubView management
- TTwistDownControl* TTwistDownView::NewTwistDownControl(TTwistDownElement* twistDownElement,
- VPoint& itsLocation, OSErr &myOSErr);
- void TTwistDownView::AddTwistDownControls(TTwistDownElement* twistDownElement, short &rowNumber, OSErr& myOSErr);
- void TTwistDownView::DeleteTwistDownControls(TTwistDownElement* twistDownElement);
- void TTwistDownView::RestoreTwistDownControls(TTwistDownElement* twistDownElement);
- void TTwistDownView::RemoveTwistDownControl(TTwistDownElement* twistDownElement);
- void TTwistDownView::UpdateTwistDownControlLocations(TTwistDownElement* twistDownElement, short &rowNumber);
-
- // Drawing
- short TTwistDownView::GetItemTextToDisplay(short anItem, CStr63& aString);
-
- short TTwistDownView::GetTextToDisplay(GridCell aCell, CStr63& aString);
- virtual void TTwistDownView::DrawCell(GridCell aCell, const VRect& aRect);
-
- Boolean TTwistDownView::GetNewFontSize(CommandNumber aCommandNumber,long& newFontSize);
- void TTwistDownView::DoChangeTextStyle(const TextStyle& itsTextStyle);
- void TTwistDownView::DoChangeFontSize(short newFontSize);
- void TTwistDownView::DoChangeFont(CStr255 newFontName);
- void TTwistDownView::DoChangeWritingDirection(EWritingDirection newWritingDirection);
-
- VPoint TTwistDownView::GetTwistDownControlSize();
-
- void TTwistDownView::CreateTwistDownTriangles();
- PolyHandle TTwistDownView::GetOpenTriangle();
- PolyHandle TTwistDownView::GetClosedTriangle();
- PolyHandle TTwistDownView::GetIntermediateTriangle();
-
- void TTwistDownView::IncrementNumberOfControls();
- void TTwistDownView::DecrementNumberOfControls();
- long TTwistDownView::GetNumberOfControls();
-
- //These are used to manage the enabling of cExpandAll and cCollapseAll
- void TTwistDownView::IncrementNumberOfExpandedControls();
- void TTwistDownView::DecrementNumberOfExpandedControls();
-
- void TTwistDownView::IncrementNumberOfCollapsedControls();
- void TTwistDownView::DecrementNumberOfCollapsedControls();
-
- //The following four methods are used to manage error recovery from failed TExpandAllCommands
- long TTwistDownView::GetNumberOfExpandedControls();
- void TTwistDownView::SetNumberOfExpandedControlsTo(long numberOfControls);
- long TTwistDownView::GetNumberOfCollapsedControls();
- void TTwistDownView::SetNumberOfCollapsedControlsTo(long numberOfControls);
-
- //These are used to set the values of fCouldExpandAll and fCouldCollapseAll.
- void TTwistDownView::SetCantExpandAll();
- void TTwistDownView::SetCantCollapseAll();
- void TTwistDownView::SetTheCouldFlags();
-
- void TTwistDownView::IncrementInitialNumberOfControls();
- Boolean TTwistDownView::ControlCountingEnabled();
-
- // Scripting support
- virtual void TTwistDownView::DoScriptCommand(CommandNumber aCommandNumber,TAppleEvent* message,TAppleEvent* reply);
- virtual DescType TTwistDownView::GetSpecifierForm();
- virtual Boolean TTwistDownView::GetObjectProperty(CAEDesc& thePropertyValue,DescType whichProperty,
- const CAEDesc& desiredType);
-
- virtual void TTwistDownView::GetSetPropertyInfo(DescType whichProperty,CommandNumber& cmdNum,
- Boolean& canUndo,Boolean& causesChange,TCommandHandler* &theContext);
-
- virtual void TTwistDownView::SetObjectProperty(const CAEDesc& thePropertyValue,DescType whichProperty);
- };
-
- //----------------------------------------------------------------------------------------
- // Global initialization procedure
- //----------------------------------------------------------------------------------------
- extern void InitUTwistDownView();
-
- #endif
-